package pattern1;

/**
 * @author wdl
 */
public abstract class AbstractOperation {
    protected double numberA;
    protected double numberB;

    /**
     * @return 放回计算的结果方法
     */
    abstract double getResult();
}

class OperationAdd extends AbstractOperation {
    @Override
    double getResult() {
        return numberA + numberB;
    }
}

class OperationSub extends AbstractOperation {

    @Override
    double getResult() {
        return numberA - numberB;
    }
}

class OperationMul extends AbstractOperation {

    @Override
    double getResult() {
        return numberA * numberB;
    }
}

class OperationDiv extends AbstractOperation {
    @Override
    double getResult() {
        return numberA / numberB;
    }
}